local mingjiao = fk.CreateSkill{
  name = "wk_heg__mingjiao",
  tags = {Skill.Compulsory}
}

local HG = require "packages/new_heg_diy_my/util"

Fk:loadTranslationTable{
  ["wk_heg__mingjiao"] = "鸣角",
  [":wk_heg__mingjiao"] = "锁定技，①【南蛮入侵】对你无效；②当你首次明置此武将牌后，你获得两张<a href= ':Heg__policy'>“战策”</a>；③当你失去一张<a href= ':Heg__policy'>“战策”</a>后，你获得一张“战策”",

  ["$wk_heg__mingjiao1"] = "吾有蛮勇可攻，亦有蛮智可御。",
  ["$wk_heg__mingjiao2"] = "远交近攻之法，怎可不为我所用。",
}

mingjiao:addEffect(fk.PreCardEffect, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(mingjiao.name) and data.card.trueName == "savage_assault" and player == data.to
  end,
  on_use = function (self, event, target, player, data)
    data.nullified = true
  end,
})

mingjiao:addEffect(fk.GeneralRevealed, {
  can_trigger = function (self, event, target, player, data)
    if player:hasSkill(mingjiao.name) and player == target and player:usedEffectTimes(self.name, Player.HistoryGame) == 0 then
      for _, v in pairs(data) do
        if table.contains(Fk.generals[v]:getSkillNameList(), mingjiao.name) then return true end
      end
    end
  end,
  on_use = function (self, event, target, player, data)
    HG.GetPolicy(player.room, player, 2, self.name)
  end,
})

mingjiao:addEffect(HG.HegLosePolicy, {
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(mingjiao.name) and data[1] == player
  end,
  on_use = function (self, event, target, player, data)
    HG.GetPolicy(player.room, player, 1, self.name)
  end,
})

return mingjiao